#include <iostream>
#include <vector>

using namespace std;

const int N = 1e6 + 10;

int ne[N];
string s1, s2;

void get_next()
{
	int m = s2.size();
//	cout <<"m:" << m << endl;
	ne[0] = -1; ne[1] = 0;
	int i = 2, cn = 0;
	while(i <= m)
	{
		if(s2[i - 1] == s2[cn]) 
		{
			ne[i++] = ++cn;
		}
		else if(cn > 0)
		{
			cn = ne[cn];
		}
		else 
		{
			ne[i++] = 0;
		}
	}
}

vector<int> kmp()
{
	vector<int> ret;

	int n = s1.size(), m = s2.size();
	int x = 0, y = 0;
	while(x < n)
	{

		if(s1[x] == s2[y]) 
		{
			x++; y++;
		}
		else if(y == 0)
		{
			x++; 
		}
		else 
		{
			y = ne[y];                                                                                                        
		}
		if(y == m)
		{
			ret.push_back(x - y + 1);
//			y = 0; x = x - y + 1;
		}
	}
	return ret;
}

int main()
{
	cin >> s1 >> s2;
	get_next();
	vector<int> ans = kmp();
	for(auto x : ans) cout << x << endl;
	
	for(int i = 1; i <= s2.size(); i++) cout << ne[i] << " ";
	return 0;
} 
